package com.pgybook.db.entity.mapper;

import org.springframework.stereotype.Repository;
import com.pgybook.db.entity.domain.Recommendation;
import com.pgybook.db.entity.domain.RecommendationEx;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.Update;

@Repository
public interface RecommendationMapper {
    int countByExample(RecommendationEx example);

    int deleteByExample(RecommendationEx example);

    @Delete({
            "delete from recommendation",
            "where RECOMMID = #{recommid,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer recommid);

    @Insert({
            "insert into recommendation (CODE, NAME, ",
            "DESCRIPTION)",
            "values (#{code,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, ",
            "#{description,jdbcType=VARCHAR})"
    })
    @SelectKey(statement = "SELECT LAST_INSERT_ID()", keyProperty = "recommid", before = false, resultType = Integer.class)
    int insert(Recommendation record);

    int insertSelective(Recommendation record);

    List<Recommendation> selectByExample(RecommendationEx example);

    @Select({
            "select",
            "RECOMMID, CODE, NAME, DESCRIPTION",
            "from recommendation",
            "where RECOMMID = #{recommid,jdbcType=INTEGER}"
    })
    @ResultMap("BaseResultMap")
    Recommendation selectByPrimaryKey(Integer recommid);

    int updateByExampleSelective(@Param("record") Recommendation record, @Param("example") RecommendationEx example);

    int updateByExample(@Param("record") Recommendation record, @Param("example") RecommendationEx example);

    int updateByPrimaryKeySelective(Recommendation record);

    @Update({
            "update recommendation",
            "set CODE = #{code,jdbcType=VARCHAR},",
            "NAME = #{name,jdbcType=VARCHAR},",
            "DESCRIPTION = #{description,jdbcType=VARCHAR}",
            "where RECOMMID = #{recommid,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(Recommendation record);
}
